package com.workspace.repository;

import com.workspace.daomain.Photo;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;
@Repository
public interface PhotoRepository extends JpaRepository<Photo,Integer> {
    //首页初步展示
    @Query(value = "SELECT * FROM photo LIMIT 12",nativeQuery = true)
    public List<Photo> findPhotos();
    //分类查询
    public List<Photo> findPhotoByCategory(Integer cid);
    //后端查询所有
    @Query(value = "SELECT * FROM photo",nativeQuery = true)
    public  List<Photo> findAllPhotos();
    //删除图库数据
    @Modifying
    @Transactional
    public void deletePhotoById(Integer id);
}
